#ifndef __Door_h
#define __Door_h

#include <Arduino.h>

// define door action pin 4
#define DOOR_ACTION_PIN 12

// The actions
typedef enum {
  DOOR_ACTION_OPEN = 1,  // 
  DOOR_ACTION_CLOSE = 0,   // 
} 
DoorActions;

// callback function
#if defined(ESP8266) || defined(ESP32)
#include <functional>
#define DOOR_CALLBACK_SIGNATURE std::function<void(unsigned int)> callback
#else
#define DOOR_CALLBACK_SIGNATURE void (*callback)(unsigned int)
#endif

class Door
{

public:
    Door(); //构造函数
    void setup();
    void loop();
    int getValue();
    Door& setCallback(DOOR_CALLBACK_SIGNATURE);

private:
    DOOR_CALLBACK_SIGNATURE;
    DoorActions action = DOOR_ACTION_CLOSE;
    long last;
    long upload_last;
    int _status;
};

#endif
